package com.wowoai.user.controller;

import com.wowoai.common.page.Pagination;
import com.wowoai.common.response.ResponseVO;
import com.wowoai.common.userInfo.CurrentUserInfo;
import com.wowoai.user.controller.req.OptionTypeLogReqVO;
import com.wowoai.user.controller.vo.OptionTypeLogPageVo;
import com.wowoai.user.convert.ScoreOptionLogConvert;
import com.wowoai.user.service.ScoreOptionLogServiceI;
import com.wowoai.user.service.UserServiceI;
import com.wowoai.user.service.dto.OptionTypeLogPageDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Slf4j
@RequestMapping("/scoreOption")
public class ScoreOptionController {

    private final ScoreOptionLogServiceI scoreOptionLogServiceI;

    public ScoreOptionController(ScoreOptionLogServiceI scoreOptionLogServiceI, UserServiceI userServiceI){
        Assert.notNull(scoreOptionLogServiceI,"scoreOptionLogServiceI 不能为空");
        Assert.notNull(userServiceI,"userServiceI 不能为空");
        this.scoreOptionLogServiceI = scoreOptionLogServiceI;
    }

    @PostMapping("/getOptionTypeLogPage")
    ResponseVO<Pagination<OptionTypeLogPageVo>> getOptionTypeLogPage(@RequestBody OptionTypeLogReqVO reqVO){
        Pagination<OptionTypeLogPageDTO> page =  scoreOptionLogServiceI.getOptionTypeLogPage(reqVO, CurrentUserInfo.getUserInfo());
        return ResponseVO.success(page.map(ScoreOptionLogConvert.INS::dto2Vo));
    }
}
